<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Get the requested schema information</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.cubrid-schema" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">cubrid_schema</h1>
  <p class="verinfo">(PECL CUBRID &gt;= 8.3.0)</p><p class="refpurpose"><span class="refname">cubrid_schema</span> &mdash; <span class="dc-title">Get the requested schema information</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.cubrid-schema-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>cubrid_schema</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$conn_identifier</code></span>  
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$schema_type</code></span>  
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$class_name</code></span> 
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$attr_name</code></span>  
  ]] ) : <span class="type">array</span></div>

  <p class="para rdfs-comment">
    The <span class="function"><strong>cubrid_schema()</strong></span> function is used to get the
    requested schema information from database. You have to designate
    <code class="parameter">class_name</code>, if you want to get information on
    certain class, <code class="parameter">attr_name</code>, if you want to get
    information on certain attribute (can be used only with CUBRID_
    SCH_ATTR_PRIVILEGE).
  </p>

  <p class="para">
  The result of the cubrid_schema function is returned as a two-dimensional
  array (column (associative array) * row (numeric array)). The following
  tables shows types of schema and the column structure of the result array to
  be returned based on the schema type.
  </p>

  <p class="para">
  <table class="doctable table">
   <caption><strong>Result Composition of Each Type</strong></caption>
    
     <thead>
      <tr>
       <th>Schema</th>
       <th>Column Number</th>
       <th>Column Name</th>
       <th>Value</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>CUBRID_SCH_CLASS</td>
       <td>1</td>
       <td>NAME</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>2</td>
       <td>TYPE</td>
       <td>0:system class 1:vclass 2:class</td>
      </tr>


      <tr>
       <td>CUBRID_SCH_VCLASS</td>
       <td>1</td>
       <td>NAME</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>2</td>
       <td>TYPE</td>
       <td>1:vclass</td>
      </tr>


      <tr>
       <td>CUBRID_SCH_QUERY_SPEC</td>
       <td>1</td>
       <td>QUERY_SPEC</td>
       <td class="empty">&nbsp;</td>
      </tr>


      <tr>
       <td>CUBRID_SCH_ATTRIBUTE / CUBRID_SCH_CLASS_ATTRIBUTE</td>
       <td>1</td>
       <td>ATTR_NAME</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>2</td>
       <td>DOMAIN</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>3</td>
       <td>SCALE</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>4</td>
       <td>PRECISION</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>5</td>
       <td>INDEXED</td>
       <td>1:indexed</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>6</td>
       <td>NOT NULL</td>
       <td>1:not null</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>7</td>
       <td>SHARED</td>
       <td>1:shared</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>8</td>
       <td>UNIQUE</td>
       <td>1:unique</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>9</td>
       <td>DEFAULT</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>10</td>
       <td>ATTR_ORDER</td>
       <td>base:1</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>11</td>
       <td>CLASS_NAME</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>12</td>
       <td>SOURCE_CLASS</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>13</td>
       <td>IS_KEY</td>
       <td>1:key</td>
      </tr>


      <tr>
       <td>CUBRID_SCH_METHOD / CUBRID_SCH_CLASS_METHOD</td>
       <td>1</td>
       <td>NAME</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>2</td>
       <td>RET_DOMAIN</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>3</td>
       <td>ARG_DOMAIN</td>
       <td class="empty">&nbsp;</td>
      </tr>


      <tr>
       <td>CUBRID_SCH_METHOD_FILE</td>
       <td>1</td>
       <td>METHOD_FILE</td>
       <td class="empty">&nbsp;</td>
      </tr>


      <tr>
       <td>CUBRID_SCH_SUPERCLASS / CUBRID_SCH_DIRECT_SUPER_CLASS / CUBRID_SCH_SUBCLASS</td>
       <td>1</td>
       <td>CLASS_NAME</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>2</td>
       <td>TYPE</td>
       <td>0:system class 1:vclass 2:class</td>
      </tr>


      <tr>
       <td>CUBRID_SCH_CONSTRAINT</td>
       <td>1</td>
       <td>TYPE</td>
       <td>0:unique 1:index 2:reverse unique 3:reverse index</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>2</td>
       <td>NAME</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>3</td>
       <td>ATTR_NAME</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>4</td>
       <td>NUM_PAGES</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>5</td>
       <td>NUM_KEYS</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>6</td>
       <td>PRIMARY_KEY</td>
       <td>1:primary key</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>7</td>
       <td>KEY_ORDER</td>
       <td>base:1</td>
      </tr>


      <tr>
       <td>CUBRID_SCH_TRIGGER</td>
       <td>1</td>
       <td>NAME</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>2</td>
       <td>STATUS</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>3</td>
       <td>EVENT</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>4</td>
       <td>TARGET_CLASS</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>5</td>
       <td>TARGET_ATTR</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>6</td>
       <td>ACTION_TIME</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>7</td>
       <td>ACTION</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>8</td>
       <td>PRIORITY</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>9</td>
       <td>CONDITION_TIME</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>10</td>
       <td>CONDITION</td>
       <td class="empty">&nbsp;</td>
      </tr>


      <tr>
       <td>CUBRID_SCH_CLASS_PRIVILEGE / CUBRID_SCH_ATTR_PRIVILEGE</td>
       <td>1</td>
       <td>CLASS_NAME / ATTR_NAME</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>2</td>
       <td>PRIVILEGE</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>3</td>
       <td>GRANTABLE</td>
       <td class="empty">&nbsp;</td>
      </tr>


      <tr>
       <td>CUBRID_SCH_PRIMARY_KEY</td>
       <td>1</td>
       <td>CLASS_NAME</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>2</td>
       <td>ATTR_NAME</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>3</td>
       <td>KEY_SEQ</td>
       <td>base:1</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>4</td>
       <td>KEY_NAME</td>
       <td class="empty">&nbsp;</td>
      </tr>


      <tr>
       <td>CUBRID_SCH_IMPORTED_KEYS / CUBRID_SCH_EXPORTED_KEYS / CUBRID_SCH_CROSS_REFERENCE</td>
       <td>1</td>
       <td>PKTABLE_NAME</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>2</td>
       <td>PKCOLUMN_NAME</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>3</td>
       <td>FKTABLE_NAME</td>
       <td>base:1</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>4</td>
       <td>FKCOLUMN_NAME</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>5</td>
       <td>KEY_SEQ</td>
       <td>base:1</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>6</td>
       <td>UPDATE_ACTION</td>
       <td>0:cascade 1:restrict 2:no action 3:set null</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>7</td>
       <td>DELETE_ACTION</td>
       <td>0:cascade 1:restrict 2:no action 3:set null</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>8</td>
       <td>FK_NAME</td>
       <td class="empty">&nbsp;</td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>9</td>
       <td>PK_NAME</td>
       <td class="empty">&nbsp;</td>
      </tr>

     </tbody>
    
   </table>

  </p>

 </div>


<div class="refsect1 parameters" id="refsect1-function.cubrid-schema-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
  <dl>

    
  <dt>
<code class="parameter">conn_identifier</code></dt>

  <dd>
<p class="para">Connection identifier.</p></dd>

   
   
  <dt>
<code class="parameter">schema_type</code></dt>

  <dd>
<p class="para">Schema data that you want to know.</p></dd>

   
   
  <dt>
<code class="parameter">class_name</code></dt>

  <dd>
<p class="para">Class you want to know the schema of.</p></dd>

   
   
  <dt>
<code class="parameter">attr_name</code></dt>

  <dd>
<p class="para">Attribute you want to know the schema of.</p></dd>

   
  </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.cubrid-schema-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
    Array containing the schema information, when process is successful; 
  </p>
  <p class="para">
    <strong><code>FALSE</code></strong>, when process is unsuccessful
  </p>
 </div>

 
 <div class="refsect1 changelog" id="refsect1-function.cubrid-schema-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>8.3.1</td>
       <td>
        Change return value: when process is unsuccessful, return false, not -1.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.cubrid-schema-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-1145">
   <p><strong>Example #1 <span class="function"><strong>cubrid_schema()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$conn&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">cubrid_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"localhost"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">33000</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"demodb"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"dba"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"\n---&nbsp;Primary&nbsp;Key&nbsp;---\n"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$pk&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">cubrid_schema</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">CUBRID_SCH_PRIMARY_KEY</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"game"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$pk</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"\n---&nbsp;Foreign&nbsp;Keys&nbsp;---\n"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$fk&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">cubrid_schema</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">CUBRID_SCH_IMPORTED_KEYS</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"game"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$fk</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"\n---&nbsp;Column&nbsp;Attribute&nbsp;---\n"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$attr&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">cubrid_schema</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">CUBRID_SCH_ATTRIBUTE</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"stadium"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"area"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$attr</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">cubrid_disconnect</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
   </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>

--- Primary Key ---
array(3) {
  [0]=&gt;
  array(4) {
    [&quot;CLASS_NAME&quot;]=&gt;
    string(4) &quot;game&quot;
    [&quot;ATTR_NAME&quot;]=&gt;
    string(12) &quot;athlete_code&quot;
    [&quot;KEY_SEQ&quot;]=&gt;
    string(1) &quot;3&quot;
    [&quot;KEY_NAME&quot;]=&gt;
    string(41) &quot;pk_game_host_year_event_code_athlete_code&quot;
  }
  [1]=&gt;
  array(4) {
    [&quot;CLASS_NAME&quot;]=&gt;
    string(4) &quot;game&quot;
    [&quot;ATTR_NAME&quot;]=&gt;
    string(10) &quot;event_code&quot;
    [&quot;KEY_SEQ&quot;]=&gt;
    string(1) &quot;2&quot;
    [&quot;KEY_NAME&quot;]=&gt;
    string(41) &quot;pk_game_host_year_event_code_athlete_code&quot;
  }
  [2]=&gt;
  array(4) {
    [&quot;CLASS_NAME&quot;]=&gt;
    string(4) &quot;game&quot;
    [&quot;ATTR_NAME&quot;]=&gt;
    string(9) &quot;host_year&quot;
    [&quot;KEY_SEQ&quot;]=&gt;
    string(1) &quot;1&quot;
    [&quot;KEY_NAME&quot;]=&gt;
    string(41) &quot;pk_game_host_year_event_code_athlete_code&quot;
  }
}

--- Foreign Keys ---
array(2) {
  [0]=&gt;
  array(9) {
    [&quot;PKTABLE_NAME&quot;]=&gt;
    string(7) &quot;athlete&quot;
    [&quot;PKCOLUMN_NAME&quot;]=&gt;
    string(4) &quot;code&quot;
    [&quot;FKTABLE_NAME&quot;]=&gt;
    string(4) &quot;game&quot;
    [&quot;FKCOLUMN_NAME&quot;]=&gt;
    string(12) &quot;athlete_code&quot;
    [&quot;KEY_SEQ&quot;]=&gt;
    string(1) &quot;1&quot;
    [&quot;UPDATE_RULE&quot;]=&gt;
    string(1) &quot;1&quot;
    [&quot;DELETE_RULE&quot;]=&gt;
    string(1) &quot;1&quot;
    [&quot;FK_NAME&quot;]=&gt;
    string(20) &quot;fk_game_athlete_code&quot;
    [&quot;PK_NAME&quot;]=&gt;
    string(15) &quot;pk_athlete_code&quot;
  }
  [1]=&gt;
  array(9) {
    [&quot;PKTABLE_NAME&quot;]=&gt;
    string(5) &quot;event&quot;
    [&quot;PKCOLUMN_NAME&quot;]=&gt;
    string(4) &quot;code&quot;
    [&quot;FKTABLE_NAME&quot;]=&gt;
    string(4) &quot;game&quot;
    [&quot;FKCOLUMN_NAME&quot;]=&gt;
    string(10) &quot;event_code&quot;
    [&quot;KEY_SEQ&quot;]=&gt;
    string(1) &quot;1&quot;
    [&quot;UPDATE_RULE&quot;]=&gt;
    string(1) &quot;1&quot;
    [&quot;DELETE_RULE&quot;]=&gt;
    string(1) &quot;1&quot;
    [&quot;FK_NAME&quot;]=&gt;
    string(18) &quot;fk_game_event_code&quot;
    [&quot;PK_NAME&quot;]=&gt;
    string(13) &quot;pk_event_code&quot;
  }
}

--- Column Attribute ---
array(1) {
  [0]=&gt;
  array(13) {
    [&quot;ATTR_NAME&quot;]=&gt;
    string(4) &quot;area&quot;
    [&quot;DOMAIN&quot;]=&gt;
    string(1) &quot;7&quot;
    [&quot;SCALE&quot;]=&gt;
    string(1) &quot;2&quot;
    [&quot;PRECISION&quot;]=&gt;
    string(2) &quot;10&quot;
    [&quot;INDEXED&quot;]=&gt;
    string(1) &quot;0&quot;
    [&quot;NON_NULL&quot;]=&gt;
    string(1) &quot;0&quot;
    [&quot;SHARED&quot;]=&gt;
    string(1) &quot;0&quot;
    [&quot;UNIQUE&quot;]=&gt;
    string(1) &quot;0&quot;
    [&quot;DEFAULT&quot;]=&gt;
    NULL
    [&quot;ATTR_ORDER&quot;]=&gt;
    string(1) &quot;4&quot;
    [&quot;CLASS_NAME&quot;]=&gt;
    string(7) &quot;stadium&quot;
    [&quot;SOURCE_CLASS&quot;]=&gt;
    string(7) &quot;stadium&quot;
    [&quot;IS_KEY&quot;]=&gt;
    string(1) &quot;0&quot;
  }
}
</pre></div>
   </div>
  </div>
 </div>


</div></div></div></body></html>